#ifndef REGRESSIONANALYSIS_H
#define REGRESSIONANALYSIS_H
#include <QObject>
#include <QtCore>
#include <QString>
#include <QHash>
#include "stock.h"
class RegressionAnalysis : public QObject
{
    Q_OBJECT

public:
    RegressionAnalysis();
    Stock *stock;
    void setStockData(Stock *stockData);
    QString getB0();
    QString getB1();
    QString getCalculateXmean();
    QString getCalculateYmean();
    QString getSumSquareDeviationX();
    QString getSumSquareDeviationY();
    QString getSumDeviationXY();
    QString getYfromEquation(QString X);

private:
    QString  calculateXmean;
    QString calculateYmean;
    QHash<qint16, qint64> deviationX;
    QHash<qint16, qint64> deviationY;
    QHash<qint16, qint64> squareDeviationX;
    QHash<qint16, qint64> squareDeviationY;
    QHash<qint16, qint64> deviationXY;
    QString sumSquareDeviationX;
    QString sumSquareDeviationY;
    QString sumDeviationXY;
    QString b0;
    QString b1;

    void setCalculateXmean(QString cXmean);
    void setCalculateYmean(QString cYmean);
    void setDeviationX(QHash<qint16, qint64> xData);
    void setDeviationY(QHash<qint16, qint64> yData);
    void setSquareDeviationX(QHash<qint16, qint64> squareDX);
    void setSquareDeviationY(QHash<qint16, qint64> squareDY);
    void setDeviationXY(QHash<qint16, qint64> dataXY);
    void setSumDeviationXY(QString xyData);
    void setSumSquareDeviationX(QString xData);
    void setSumSquareDeviationY(QString yData);
    void setB0(QString value);
    void setB1(QString value);

    void calculateDeviationX(Stock *stockData, QString cXmean);
    void calculateDeviationY(Stock *stockData, QString cYmean);
    void calculateSquareDeviationX(QHash<qint16, qint64> devX);
    void calculateSquareDeviationY(QHash<qint16, qint64> devY);
    QHash<qint16, qint64> getDeviationX();
    QHash<qint16, qint64> getDeviationY();
    QHash<qint16, qint64> getDeviationXY();
    QHash<qint16, qint64> getSquareDeviationX();
    QHash<qint16, qint64> getSquareDeviationY();
    void calculateDeviationXY(QHash<qint16, qint64> xData, QHash<qint16, qint64> yData);
    QString calculateSumSquareDeviationX(QHash<qint16, qint64> xData);
    QString calculateSumSquareDeviationY(QHash<qint16, qint64> yData);
    QString calculateSumDeviationXY(QHash<qint16, qint64> xyData);
};


#endif // REGRESSIONANALYSIS_H
